dojo.declare("MobileMainPg", wm.Page, {
    start: function() {
        this.vLoginCount = 1;
    },
    "preferredDevice": "phone",

    loginButtonClick: function(inSender) {
        this.loginErrorMsg.setCaption("");
        dojo.cookie("user", this.usernameInput.getDataValue(), {
            expires: 365
        });
    },

    onLoginSuccess: function() {
        if (window["PhoneGap"]) {
            this.phonegapCredentialStorage.setData({
                name: this.usernameInput.getDataValue(),
                dataValue: this.passwordInput.getDataValue()
            });
        }
    },
    loginFailed: function(inResponse) {
        this.loginErrorMsg.setCaption("Invalid username or password.");
      
        this.usernameInput.focus();
    },

    label1ReadOnlyNodeFormat: function(inSender, inValue) {
        return app.xhrPath;
    },
    pictureLogoutClick: function(inSender) {
        wm.Page.getPage("MobileMainPg").ncLoginPg.update();

        //this.pictureHome.setShowing(false);
        this.pictureLogout.setShowing(false);

        if (wm.Page.getPage("MRegistrationPg")) {

            wm.Page.getPage("MRegistrationPg").populatePhonegapCredentials();
        }
    },
    pictureHomeClick: function(inSender) {

        var mainPage = wm.Page.getPage("MobileMainPg");

        if (mainPage.vUserRole === 'CUSTOMER') {
            if (wm.Page.getPage("MCustomerHomePg")) {
                wm.Page.getPage("MCustomerHomePg").tbServices.click();
            }
            // mainPage.ncCustomerService.update();
        } else if (mainPage.vUserRole === 'VENDOR') {
            if (wm.Page.getPage("MVendorHomePg")) {
                wm.Page.getPage("MVendorHomePg").tbServices.click();
            }
        } else if (mainPage.vUserRole === 'ADMIN') {
            mainPage.ncCustomerService.update();
        }
    },
    _end: 0
});